package juc.deadlock;

public class demo1 {
    public static void main(String[] args) {
        Object A = new Object();
        Object B = new Object();

        new Thread(()->{

            synchronized (A){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (B){
                    System.out.println("lock b");
                }
            }
        }).start();

        new Thread(()->{
            synchronized (B){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (A){
                    System.out.println("lock A");
                }
            }
        }).start();

    }
}
